﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using DigitalGenetics;
using System.Diagnostics;
using System.Drawing;

namespace Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            //Convert.ToByte(
            string str = (3.14).ToString("X");
            Console.WriteLine(str);
        }

        [TestMethod]
        public void TestSmFile()
        {
            DigitalGenetics.SumMatrix sm = new SumMatrix(@"C:\Temp\Genes\Human\chrY.fa.tcag.n-t.hex.sm");
            // C:\Temp\Genes\Human\chrY.fa.tcag.n-t.hex.sm 
            // C:\Temp\Genes\Bos_taurus - cow\Bos_taurus.UMD3.1.68.dna.chromosome.1.fa.tcag.n-t.hex.sm
            int[] a = sm.SerializedSumMatrix;
            int[,] b = sm.NormalizedSumMatrix;
            int[] c = sm.MedianValues;
            Assert.IsTrue(sm.CurrentSumMatrix[0, 0] != 0);

            Metrics metrics = new Metrics();
            sm.GetMetrics(metrics);
            Assert.IsTrue(metrics.Total.Count == 65536);
        }

        [TestMethod]
        public void TestFormat()
        {
            Debug.WriteLine(string.Format("{0:F2}%", 1.123456789f));
        }

        // --------------------------
        private static int SerializedIndex(int x, int y)
        {
            return x + y * 256;
        }
        [TestMethod]
        public void Array2Dto1()
        {
            int[,] numbers2D = new int[3, 2] { { 9, 99 }, { 3, 33 }, { 5, 55 } };
            // Or use the short form: 
            // int[,] numbers2D = { { 9, 99 }, { 3, 33 }, { 5, 55 } }; 

            foreach (int i in numbers2D)
            {
                System.Console.Write("{0} ", i);
            }
        }

        [TestMethod]
        public void TestSmGraphics()
        {
            SolidBrush[] br = SumMatrix.GreyBrushArray;
            Assert.IsTrue(br[1].Color.R == 1);
            Assert.IsTrue(br[1].Color.G == 1);
            Assert.IsTrue(br[1].Color.B == 1);
        }

        [TestMethod]
        public void Test4_3File()
        {
            //string hexFile = @"C:\Temp\Genes\Human\chrY.fa.tcag.n-t.hex";
            string hexFile = @"C:\Temp\Genes\Drosophila_melanogaster\chrX.fa.hex";
            string fourThirdFile = hexFile + ".4_3";
            string sm4_3File = fourThirdFile + ".sm";
            DigitalGenetics.SumMatrix.HexTo4_3(hexFile, fourThirdFile);

            DigitalGenetics.SumMatrix sm = new SumMatrix();
            sm.Hex2Sm(fourThirdFile, sm4_3File);
        }


    }
}
